import { useSelector, useDispatch } from 'react-redux';
import type { RootState } from '../store';
import { toggleTheme, setTheme } from '../store/slices/themeSlice';
import type { ThemeMode } from '../types/theme';

export const useTheme = () => {
  const dispatch = useDispatch();
  const themeMode = useSelector((state: RootState) => state.theme.mode);

  const toggle = () => {
    dispatch(toggleTheme());
  };

  const set = (theme: ThemeMode) => {
    dispatch(setTheme(theme));
  };

  const isLight = themeMode === 'light';
  const isDark = themeMode === 'dark';

  return {
    theme: themeMode,
    isLight,
    isDark,
    toggle,
    set,
  };
}; 